<template>
  <view class="center">
    <view class="van_row" @click="getNav('position')">
      <image src="../../static/icon/position.png"></image>
      <p>位置信息</p>
      <!-- <navigator url="./position" open-type="navigate"> 位置信息 </navigator> -->
    </view>
    <view class="van_row" @click="getNav('ride')">
      <image src="../../static/icon/power.png"></image>
      <p>安全骑行</p>
    </view>
    <view class="van_row" @click="getNav('system')">
      <image src="../../static/icon/setting.png"></image>
      <p>系统设置</p>
    </view>
    <view class="van_row" @click="getNav('electric')">
      <image src="../../static/icon/battery.png"></image>
      <p>电池电量</p>
    </view>
  </view>
</template>

<script>
export default {
  name: "layout",
  props: {
    is_login: Boolean,
  },
  data() {
    return {};
  },
  methods: {
    getNav(nav) {
      // this.is_login
      if (this.is_login) {
        console.log(nav);
        if (nav == "ride") {
          this.$parent.changeAlertState(true);
        }
        uni.navigateTo({
          url: "/pages/index/" + nav,
          fail: (err) => {
            console.log(err);
          },
        });
      } else {
        uni.showToast({
          icon: "none",
          title: "尚未登录，请先登录！",
          duration: 2500,
          success: (res) => {
            setTimeout(() => {
              uni.reLaunch({
                url: `/pages/mine/mine`,
                fail: (err) => {
                  console.log(err);
                },
                success() {
                  console.log("switchTab success");
                  // beforePage.onLoad();
                },
              });
            }, 1000);
          },
        });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.center {
  width: 730rpx;
  font-size: 24rpx;
  color: #595959;
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin-top: 20rpx;
  background-color: white;
  padding: 15px 0;
  border-radius: 10px;

  .van_row {
    text-align: center;
    padding: 0 16rpx;
    image {
      width: 60rpx;
      height: 60rpx;
    }

    p {
      padding-top: 20rpx;
      width: 150rpx;
    }
  }
}
</style>